﻿using ELab.Communication.Messages.ControllerMessages;
using ELab.Serialization;
using ELab.Serialization.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ELab.Communication.Messages.ControllerMessages
{ 
    public class CheckAuthenticationResponseMessage : ControlMessage
    {
        /// <summary>
        /// Gets MessageTypeId for GetApplicationListResponseMessage.
        /// </summary>
        public override int MessageTypeId
        {
            get { return ControlMessageFactory.MessageTypeIdCheckAuthenticationResponseMessage; }
        }

        /// <summary>
        /// Response check success or not
        /// </summary>
        public bool IsSuccess { get; set; }

        /// <summary>
        /// Current user when login succecc.
        /// </summary>
        public User UserLogin { get; set; }

        /// <summary>
        /// Serializes this message.
        /// </summary>
        /// <param name="serializer">Serializer used to serialize objects</param>
        public override void Serialize(IELabSerializer serializer)
        {
            base.Serialize(serializer);
            serializer.WriteBoolean(IsSuccess);
            serializer.WriteObject(UserLogin);
        }

        /// <summary>
        /// Deserializes this message.
        /// </summary>
        /// <param name="deserializer">Deserializer used to deserialize objects</param>
        public override void Deserialize(IELabDeserializer deserializer)
        {
            base.Deserialize(deserializer);
            IsSuccess = deserializer.ReadBoolean();
            UserLogin = deserializer.ReadObject(() => new User());
        }
    }
}
